<template>
	<u-tabbar :value="current" inactiveColor="#707070" activeColor="#000" :fixed="true" :placeholder="true"
		:safeAreaInsetBottom="true">
		<u-tabbar-item @click="gotonav" v-for="(item,index) in list" :key="index" :text="item.name">
			<image class="icon" slot="active-icon" :src="item.iconSel"></image>
			<image class="icon" slot="inactive-icon" :src="item.icon"></image>
		</u-tabbar-item>
	</u-tabbar>
</template>

<script>
	export default {
		name: "newTab",
		data() {
			return {
				list: [{
						name: '合作',
						iconSel: '/static/img/tabbar/home_sel.png',
						icon: '/static/img/tabbar/home_nor.png',
						path: '/other/index/index',
					},
					{
						name: '我要开店',
						iconSel: '/static/img/tabbar/coupon_sel.png',
						icon: '/static/img/tabbar/coupon_nor.png',
						path: '/other/join/join',
					},
					{
						name: '更多信息',
						iconSel: '/static/img/tabbar/member_sel.png',
						icon: '/static/img/tabbar/member_nor.png',
						path: '/other/more/more',
					}
				]
			};
		},
		computed: {

			current() {
				let currentIndex = 0;
				let pages = getCurrentPages();
				let fullpath = '/' + pages[pages.length - 1].route;
				this.list.map((item, idx) => {
					if (fullpath == item.path) {
						currentIndex = idx;
					}
				})
				return currentIndex || 0;
			}
		},
		
		methods: {
			gotonav(index) {
				console.info(this.list);
				if (index == this.current) {
					return;
				}
				uni.reLaunch({
					url: this.list[index].path
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.icon {
		width: 56rpx;
		height: 56rpx;
	}
</style>